package com.gitee.wsl.compose.mvi.ui.snackbarhost

import androidx.compose.material3.SnackbarHost
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.gitee.wsl.compose.mvi.component.Projector
import com.gitee.wsl.compose.mvi.ui.snackbar.Snackbar
import com.gitee.wsl.compose.mvi.ui.snackbar.SnackbarInteractor


class SnackbarHostProjector(
    interactor: SnackbarHostInteractor = SnackbarHostInteractor.Default,
    presenter: SnackbarHostPresenter = SnackbarHostPresenter.Default
) : Projector<SnackbarHostInteractor, SnackbarHostPresenter>(interactor, presenter) {

    @Composable
    override fun body(
        combinedModifier: Modifier,
        interactor: SnackbarHostInteractor,
        presenter: SnackbarHostPresenter,
    ) {
        SnackbarHost(
            hostState = interactor.state,
            modifier = combinedModifier,
        ) { data ->
            Snackbar(
                interactor = SnackbarInteractor(data = data),
                presenter = presenter.snackbar
            )
        }
    }
}